var userRed={
	tel: $('input[type="tel"]'),
	veri: $('input[type="text"]'),
	downTime: $('.mui-row .mui-col-xs-2'),
	btn: $('.btn'),
	time :null,
	valiTel: function(t){
		var tel=this.tel.val();
		var reg=/^1[3,5,7,8,9]\d{9}$/;
		if(tel == '' || !reg.test(tel)){
			app.log('请输入正确的手机号码！');
			this.tel.focus();
			return;
		}
		
		(t == 'v') && this.sliceNum();
	},
	sliceNum: function(){
		this.time=setInterval(function(){
			var t=$('.mui-row .mui-col-xs-2').text();
			t = parseInt(t.substring(0,t.length-1));
			console.log(t);
			if(t == 0){
				t=59;
				clearInterval(this.time);
			}else{
				t--;
			}
			$('.mui-row .mui-col-xs-2').text(t+'s');
			
		},1000);
	},
	valiVeri: function(){
		var v=this.veri.val();
		if(v == '1234'){
			app.log('验证码正确');
			clearInterval(this.time);
		}else{
			app.log('验证码错误，请重新输入');
			this.veri.focus();
			return;
		}
	},
	btnSub: function(){
		this.valiTel('b');
		this.valiVeri();
		app.log('提交成功');
	}
}


window.onload = function(){
	$('body').on('blur','.mui-col-xs-10 input',function(){
		userRed.valiTel();
	});
	
	$('body').on('blur','.veri input',function(){
		userRed.valiVeri();
	});
	
	$('body').on('click','.btn',function(){
		userRed.btnSub();
	});
};
